package com.wsjzzcbq.qianyuan.sys.controller;

import com.alibaba.fastjson.JSONArray;
import com.wsjzzcbq.qianyuan.common.bean.R;
import com.wsjzzcbq.qianyuan.sys.param.FindMenuParam;
import com.wsjzzcbq.qianyuan.sys.param.MenuParam;
import com.wsjzzcbq.qianyuan.sys.service.MenuService;
import com.wsjzzcbq.qianyuan.sys.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * SysMenuController
 *
 * @author wsjz
 * @date 2022/03/18
 */
@RequestMapping("/sys/menu")
@RestController
public class SysMenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/findMenuList")
    public R<List<MenuVo>> findMenuList(FindMenuParam param) {
        return menuService.findMenuList(param);
    }

    @GetMapping("/findJSONArrayMenuList")
    public R<JSONArray> findJSONArrayMenuList() {
        return R.success(menuService.menuPermission());
    }

    @PostMapping("/addOrUpdate")
    public R<?> addOrUpdate(@RequestBody @Valid MenuParam param) {
        return menuService.addOrUpdate(param);
    }

    @GetMapping("/findMenuVoById")
    public R<MenuVo> findMenuVoById(String id) {
        return menuService.findMenuVoById(id);
    }

    @DeleteMapping("/deleteMenuById")
    public R<?> deleteMenuById(String id) {
        return menuService.deleteMenuById(id);
    }
}
